package com.tgy.admin.controller;

import com.tgy.admin.Service.AdminArticleService;
import com.tgy.admin.Service.AdminUserService;
import com.tgy.result.GraceJSONResult;
import com.tgy.vo.StatisticsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author tianguiyin
 * @version 1.0
 * @date 2022/7/29 22:40
 */
@Validated
@Api(value = "首页统计控制器", tags = {"首页统计管理"})
@RestController
@RequestMapping("/admin/statistics")
public class StatisticsController {

    @Resource
    private AdminArticleService adminArticleService;
    @Resource
    private AdminUserService adminUserService;



    @ApiOperation("获取统计数据")
    @GetMapping("/getStatisticsNumber")
    public GraceJSONResult getStatisticsNumber() {
        StatisticsVo vo = adminArticleService.getStatisticsNumber();
        return GraceJSONResult.ok(vo);
    }

    @ApiOperation("获取最受欢迎前5top")
    @GetMapping("/getArticleTopTen")
    public GraceJSONResult getArticleTopTen() {
        Map<String,Object> map = adminArticleService.getArticleTopTen();
        return GraceJSONResult.ok(map);
    }

    @ApiOperation("获取最受欢迎前5top")
    @GetMapping("/getUserTopTen")
    public GraceJSONResult getUserTopTen() {
        Map<String,Object> map = adminArticleService.getUserTopTen();
        return GraceJSONResult.ok(map);
    }

}
